import { NgModule } from '@angular/core';
import { RouterModule, NavigationEnd, Router } from '@angular/router';
import { RoomIndexComponent } from './rooms/room-index.component';
import { LocationComponent } from './rooms/location.component';
import { ToolBaseInfoComponent } from './tool/base/tool-base-info.component';
import { ToolAccountComponent } from './tool/account/tool-account.component';
import { ToolDeptAccountComponent } from './tool/account/tool-dept-account.component';
import { ToolIntoComponent } from './tool/into/tool-into.component';
import { ToolReceiveComponent } from './tool/receive/tool-receive.component';
import { ToolScrapComponent } from './tool/scrap/tool-scrap.component';
import { ToolInventoryComponent } from './tool/inventory/tool-inventory.component';
import { ToolBorrowComponent } from './tool/borrow/tool-borrow.component';
import { ToolBorrowOutComponent } from './tool/borrowout/tool-borrow-out.component';
import { ToolCancelComponent } from './tool/cancel/tool-cancel.component'; 
import { ToolReturnComponent } from './tool/return/tool-return.component';
import { SupplierComponent } from './supplier/supplier-index.component';
import { ToolTransferComponent } from './tool/tooltransfer/tool-transfer.component';
import { ToolSearchReceiveComponent } from './tool/receive/tool-search-receive.component';
import { ToolMaintainComponent } from './tool/maintain/tool-maintain.component';
import { ToolMaintainAccountComponent } from './tool/account/tool-maintain-account.component';
import { ToolLostAccountComponent } from './tool/lost/tool-lost-account.component';
import { ToolLostIndexComponent } from './tool/lost/tool-lost-index.component';

@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                    // 库房
                    { path: 'rooms', component: RoomIndexComponent },
                    //库位
                    { path: 'locations', component: LocationComponent },
                    // 供应商
                    { path: 'supplier', component: SupplierComponent },
                    
                    // 工具
                    { path: 'tool-baseinfo', component: ToolBaseInfoComponent },
                    { path: 'tool-account', component: ToolAccountComponent },
                    { path: 'tool-deptaccount', component: ToolDeptAccountComponent },
                    { path: 'tool-mtainaccount', component: ToolMaintainAccountComponent },
                    { path: 'tool-into', component: ToolIntoComponent },
                    { path: 'tool-receive', component: ToolReceiveComponent },
                    { path: 'tool-scrap', component: ToolScrapComponent },
                    { path: 'tool-maintain', component: ToolMaintainComponent },
                    { path: 'tool-inventory', component: ToolInventoryComponent },
                    { path: 'tool-borrowin', component: ToolBorrowComponent },
                    { path: 'tool-borrowout', component: ToolBorrowOutComponent },
                    { path: 'tool-cancel', component: ToolCancelComponent },
                    { path: 'tool-return', component: ToolReturnComponent },
                    { path: 'tool-transfer', component: ToolTransferComponent },
                    { path: 'tool-searchreceive', component: ToolSearchReceiveComponent },
                    { path: 'tool-lostindex', component: ToolLostIndexComponent },
                    { path: 'tool-lostaccount', component: ToolLostAccountComponent },
                ]
            }
        ])
    ],
    exports: [RouterModule]
})
export class StockRoutingModule {
    constructor(private router: Router) {
        router.events.subscribe(event => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }
}
